<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
  <title>导入登船人员</title>
  <%@ include file="/include/openstyles.jsp" %>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/jquery.validate.min.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/validate-methods.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/jquery/jquery-form.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/input.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/lui.jiantingdiv.js"></script>
  <script type="text/javascript" src="${ctx}/assets/uc/js/common.js"></script>
  <style>
    .help-block {
      margin: 0px !important;
    }
  </style>
</head>
<body>
<div class="row">
  <div class="col-xs-12">
    <div class="space-12"></div>
    <form class="form-horizontal" role="form" id="user_upload_form" method="post" action="${ctx}/user/import-method" enctype="multipart/form-data">
      <div class="tabbable">
        <div class="profile-user-info profile-user-info-striped">
          <div class="profile-info-row">
            <div class="profile-info-name" style="width: 200px">请选择登船人员Excel文件,请严格按照规定格式填写登船人员信息：</div>
            <div class="profile-info-value">
              <input type="file" id="ucFile" name="ucFile"
                     class="col-xs-10 col-sm-8"/>
            </div>
          </div>

        </div>
      </div>
      <div id="maskf" style="position: relative;top:-88px;left:0;width: 100%;height: 70%;background-color: #cccccc;opacity:0.9;display: none;">文件正在上传，请耐心等待...</div>
    </form>
  </div>
</div>


<script type="text/javascript">

  var form = "user_upload_form";
  var $form = $("#" + form);

  jQuery(function ($) {
    $form.validate({
      rules: {
        'userFile': {
          required: true
        }
      },

      messages: {
        'userFile': {
          required: "必须选择文件"
        }
      }
    });

  });

  function formValid() {
    var retObj = new Object();
    if ($("#user_upload_form").valid()) {
      var index = layer.load(2);
      $('#user_upload_form').ajaxSubmit({
        url: "${ctx}/${frameworkPath}/user/importStaff",
        type: "post",
        async: false,
        dataType: 'json',
        data:{vesselId:'${param.vesselId}'},
          beforeSend:function () {
            $('#maskf').css('display',"block");
            debugger;

          },
        success: function (message) {
          if (message.success) {
            layer.close(index);
            retObj.text = message.Message;
            retObj.state = true;

          }
          else {
            retObj.text = "保存失败！";
            retObj.state = false;
          }
        }
      });
    }
    return retObj;
  }
</script>
</body>
</html>